package com.neuedu.amqp.consumer.config;

import org.springframework.amqp.core.Binding;
import org.springframework.amqp.core.BindingBuilder;
import org.springframework.amqp.core.FanoutExchange;
import org.springframework.amqp.core.Queue;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * @author 金山
 * 项目：sca-all-in-one
 * site: https://blog.fulfill.com.cn
 * 描述
 * @data 2025/6/610:30
 */
@Configuration
public class FanoutExchangeConfig {

    // 声明对交换机
    @Bean
    public FanoutExchange fanoutExchange() {
        return new FanoutExchange("yyzx.fanout1");
    }

    // 声明对队列  1
    // @Bean("fanoutQueue1")
    @Bean
    public Queue fanoutQueue1() {
        return new Queue("fanout1.queue1");
    }

    // 绑定关系  交换机 和队列1
    @Bean
    public Binding bindingQueue1(Queue fanoutQueue1, FanoutExchange fanoutExchange) {
        return BindingBuilder.bind(fanoutQueue1).to(fanoutExchange);
    }

    // 声明对队列  2
    // @Bean("fanoutQueue2")
    @Bean
    public Queue fanoutQueue2() {
        return new Queue("fanout1.queue2");
    }

    // 绑定关系  交换机 和队列2

    @Bean
    public Binding bindingQueue2(Queue fanoutQueue2, FanoutExchange fanoutExchange) {
        return BindingBuilder.bind(fanoutQueue2).to(fanoutExchange);
    }

}
